<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/3/29
 * Time: 15:34
 */

namespace app\admin\controller;


use think\Db;
use think\Request;

class Feedback extends Base
{
    /**
     * 问题反馈列表
     * @return mixed|\think\response\Json
     */
    public function index(){
        if(Request::instance()->isAjax()){
            $Nowpage = input('page') ? input('page') : 1;
            $limits = input("limit") ? input("limit") : 10;
            $count = Db::name('feedback')
                ->join('up_u_user', 'user_id = feedback_user_id', 'left')
                ->count();// 获取总条数
            $lists = Db::name('feedback')
                ->join('up_u_user', 'user_id = feedback_user_id', 'left')
                ->field('feedback_user_id, user_username, feedback_time, feedback_content, feedback_id')
                ->page($Nowpage,$limits)
                ->order('feedback_time desc')
                ->select();
            return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
        }
        return $this->fetch();
    }
    
    /**
     * 删除问题反馈
     * @return \think\response\Json
     */
    public function feedbackDel(){
        $feedback_id = input('id');
        $res = Db::table('up_feedback')->delete($feedback_id);
        if($res){
            return json(['code' => 200, 'msg' => '操作成功']);
        }else{
            return json(['code' => 100, 'msg' => '操作失败']);
        }
    }
}